home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 4
/
Aminet 4 - November 1994.iso
/
aminet
/
comm
/
term
/
vltj5867.lha
/
VLT
/
rexx
/
AutoWrap.vlt
< prev
next >
Wrap
Text File
|
1994-03-27
|
2KB
|
71 lines
/** AutoWrap.vlt
*
* Example program to intercept keystrokes.
* This one implements automatic wrapping.
*
**/
margincol = 72
/*
* Add libraries if necessary
*/
if show("l", "rexxarplib.library") = 0 then do
check = addlib('rexxsupport.library', 0, -30, 0)
check = addlib('rexxarplib.library', 0, -30, 0)
end
/*
* Open a port
*/
mp = openport(MARGIN_BELL)
/*
* Tell VLT to send us stuff
*/
"wedge keystrokes MARGIN_BELL"
/*
* Loop until quitflag is 1, waiting for packets
*/
do forever
if quitflag = 1 then leave
t = waitpkt(MARGIN_BELL)
/*
* We got a number of packets. Loop over all of them.
*/
do ff = 1
p = getpkt(MARGIN_BELL)
if c2d(p) = 0 then leave ff
line = getarg(p)
/*
* Got something. Find out what...
*/
parse var line command code qual iaddr char .
/*
* If we got an "esc", quit.
*/
if char = '1B'x then do
quitflag = 1
"$1: BEEP; delay .7; BEEP; delay .7; BEEP"
end
/*
* Else check the current cursor x position. Send VLT a BEEP command if it
* is at the margin column.
*/
else do
"extract x"
if VLT.x >= margincol then do
"extract reviewlineatcursor"
s = reverse(VLT.reviewlineatcursor)
n = index(s, " ")
if n > 0 then do
"send ("copies('08'x, n)")"
"emit ("copies('08'x, n)")"
if n > 1 then do
"send (*R"reverse(substr(s, 1, n - 1))")"
"emit (*R"reverse(substr(s, 1, n - 1))")"
end
end
end
end
t = reply(p, 1)
end
end